package client.comm.baoding.adapter

import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.graphics.Paint
import android.text.Layout
import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView
import client.comm.baoding.R
import client.comm.baoding.api.bean.GoodsIndex
import client.comm.baoding.databinding.LayoutJxhwItemBinding
import client.comm.baoding.databinding.LayoutTjhwBinding
import client.comm.baoding.ui.GoodsDetailActivity
import client.comm.baoding.utils.TextTool
import client.comm.commlib.base.BaseListAdapter
import client.comm.commlib.base.BindingViewHoder
import client.comm.commlib.dipToPx
import client.comm.commlib.getScreenWidth
import com.bumptech.glide.RequestManager

/**
 * 精选商品
 */
//class TjGoodAdapter : BaseListAdapter<GoodsIndex.TjGoods> {

//    val manager: RequestManager
//
//    constructor(context: Context, manager: RequestManager) : super(context) {
//        this.manager = manager
//    }
//
//    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
//        return BindingViewHoder(
//            DataBindingUtil.inflate(
//                layoutInflater,
//                R.layout.layout_tjhw,
//                parent,
//                false
//            )
//        )
//    }
//
//    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
//        val bindingViewHolder = holder as BindingViewHoder<ViewDataBinding>
//        val binding = bindingViewHolder.binding as LayoutTjhwBinding
//        val bean = getItem(position)
//        binding.bean = bean
//        manager.load(bean.goods_img).into(binding.img)
//
//        TextTool.getBuilder("¥").setAlign(Layout.Alignment.ALIGN_CENTER).setBold().setTextSize(10)
//            .append(bean.price.toString()).setForegroundColor(Color.parseColor("#E81837")).setBold().setTextSize(12)
//            .into(binding.tvPrice)
//        binding.tvPriceOld.apply {
//            setPaintFlags(binding.tvPriceOld.getPaintFlags() or Paint.STRIKE_THRU_TEXT_FLAG)
//        }
//
//        binding.apply {
//            when (position) {
//                0 -> {
//                    tvLabel.isVisible = true
//                    tvLabel2.isVisible = false
//                }
//                position % 2 -> {
//                    tvLabel.isVisible = true
//                    tvLabel2.isVisible = true
//                }
//                6 -> {
//                    tvLabel.isVisible = false
//                    tvLabel2.isVisible = false
//                }
//                else -> {
//                    tvLabel.isVisible = true
//                    tvLabel2.isVisible = false
//                }
//            }
//            event = this@TjGood2Adapter
//        }
//
//    }
//
//    fun itemClick(bean: GoodsIndex.TjGoods) {
//        context.startActivity(Intent(context, GoodsDetailActivity::class.java).apply {
//            putExtra("goodsId", "${bean.goods_id}")
//        })
//    }

//}